﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProjectStorageLib.Configuration
{
    public class Configuration : DatabaseEntities
    {
        public Configuration()
            : base()
        { }

        protected override void Dispose(bool flag)
        {

        }

        public IQueryable<ProjectStorageDB.Configuration> ConfigurationSettings
        {
            get { return ent.Configuration; }
        }

        public void ChangeValue(ProjectStorageDB.Configuration conf, string newValue)
        {
            try 
            {
                conf.Value = newValue;
                ent.SaveChanges();
            }
            catch (Exception)
            { throw; }
        }

        public void AddNewValue(string newValue)
        {
            ent.Configuration.AddObject(new ProjectStorageDB.Configuration()
            {
                Description = "Similarity Threshold",
                Value = newValue
            });
            ent.SaveChanges();
        }

    }
}
